package io.github.wanggit.antrpc.commons.utils;

import io.github.wanggit.antrpc.commons.constants.ConstantValues;

public abstract class ConfigPathUtil {

    private ConfigPathUtil() {
        throw new IllegalStateException();
    }

    public static String getApplicationPath(String env, String applicationName) {
        return "/" + ConstantValues.ZK_ROOT_CONFIG_NAME + "/" + env + "/" + applicationName;
    }

    public static String getSharedSpacePath(String env, String space) {
        return "/" + ConstantValues.ZK_ROOT_CONFIG_NAME + "/" + env + "/" + space;
    }

    public static String castPathToSubscribePath(String path) {
        return path.replaceFirst(
                ConstantValues.ZK_ROOT_CONFIG_NAME, ConstantValues.ZK_ROOT_SUBSCRIBE_CONFIG_NAME);
    }
}
